package com.aizhixin.lab;


import com.aizhixin.lab.docker.core.ContainerConfig;
import com.aizhixin.lab.jsrun.util.oConvertUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.net.InetAddress;

@Slf4j
@SpringBootApplication
@EnableAutoConfiguration
@EnableScheduling
@EnableAsync
@EnableConfigurationProperties({ContainerConfig.class})
public class Main {
    public static void main(String[] args) throws Exception {
        /*SpringApplication.run(Main.class, args);*/
        ConfigurableApplicationContext application = SpringApplication.run(Main.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
        String name = oConvertUtils.getString(env.getProperty("server.context-path"));
        log.info("\n----------------------------------------------------------\n\t" +
                "本机访问地址: \thttp://localhost:" + port + path + name + "\n\t" +
                "内网访问地址: \thttp://" + ip + ":" + port + path + name + "\n\t" +
                "Swagger文档: \thttp://" + ip + ":" + port + path + name + "/doc.html" + "\n\t" +
                "----------------------------------------------------------");
    }
}
